﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="companyEdit.aspx.cs" Inherits="PeisongWeb.admin.companyEdit" %>

<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<%@ Register TagName="menu" Src="controls/menu.ascx" TagPrefix="uc2" %>
<%@ Register TagName="top" Src="controls/top.ascx" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>企业编辑 - 想购网长期采购物流配送系统</title>
    <!--#include file="style.inc"-->

    <script type="text/javascript" language="javascript" src="../app_common/scripts/jquery-cn.js"></script>
    
    <script type="text/javascript">
        
        var mobilePattern=/^(13[0-9]|15[0-9]|18[6|8|9])\d{8}$/;
    
        function sellerInfoValidate() {
            var validateFields = ["txtSellerCompanyName", "txtSellerCompanyNo", "txtSellerAddress", "txtSellerLocation", "txtSellerContact", "txtSellerMobile"];

            var fisrtValidate = true;
            for (var index = 0; index < validateFields.length; index++) {
                if (document.getElementById(validateFields[index]).value.length == 0) {
                    alert("企业信息输入不完整，请完成后提交!");
                    document.getElementById(validateFields[index]).focus();
                    fisrtValidate = false;
                    break;
                }
            }
            if (!fisrtValidate) {
                return false;
            }

            if ($('#ddlSellerArea').val().length == 0) {
                alert('请选择地区!');
                $('#ddlSellerArea').focus();
                return false;
            }

            if ($('#ddlSellerPayMethod').val().length == 0) {
                alert('请选择结账方式!');
                $('#ddlSellerPayMethod').focus();
                return false;
            }

            if ($('#chxSellerIsCheck').attr('checked')) {
                if ($('#txtSellerSuggest').val().length == 0) {
                    alert('请输入审核意见!');
                    $('#txtSellerSuggest').focus();
                    return false;
                }
            }
            
            // 供应能力度
            var capabilitys = [];
            $("input[id^='chk_supplyclass_']").each(function(entryIndex, entry) {
                if ($(entry).attr('checked')) {
                    capabilitys.push($(entry).val());
                }
            });
            if (capabilitys.length == 0) {
                alert('请选择企业供应能力范围！');
                return false;
            } else {
                $('#hdSellerBusinessNatures').val(capabilitys.join(','));
            }

//            if (!mobilePattern.test($('#txtSellerMobile').val())) {
//                alert('手机号码格式不正确!');
//                $('#txtSellerMobile').focus();
//                return false;
//            }
        }
        function buyerInfoValidate() {
            var validateFields = ["txtBuyerCompanyName", "txtBuyerCompanyNo", "txtBuyerAddress", "txtBuyerContact", "txtBuyerMobile"];

            var fisrtValidate = true;
            for (var index = 0; index < validateFields.length; index++) {
                if (document.getElementById(validateFields[index]).value.length == 0) {
                    alert("企业信息输入不完整，请完成后提交!");
                    document.getElementById(validateFields[index]).focus();
                    fisrtValidate = false;
                    break;
                }
            }
            if (!fisrtValidate) {
                return false;
            }
            
            if ($('#ddl_SalesPerson').val() == '0') {
                alert('请选择销售员!');
                $('#ddl_SalesPerson').focus();
                return false;
            }
            
            if ($('#ddlBuyerArea').val().length == 0) {
                alert('请选择地区!');
                $('#ddlBuyerArea').focus();
                return false;
            }

//            if (!mobilePattern.test($('#txtBuyerMobile').val())) {
//                alert('手机号码格式不正确!');
//                $('#txtBuyerMobile').focus();
//                return false;
//            }
            
            if ($('#ddlBuyerPayMethod').val().length == 0) {
                alert('请选择结账方式!');
                $('#ddlBuyerPayMethod').focus();
                return false;
            }

            if ($('#ddlBuyerReceiveTime').val().length == 0) {
                alert('请选择送货时间!');
                $('#ddlBuyerReceiveTime').focus();
                return false;
            }

            if ($('#chxBuyerIsCheck').attr('checked')) {
                if ($('#txtBuyerSuggest').val().length == 0) {
                    alert('请输入审核意见!');
                    $('#txtBuyerSuggest').focus();
                    return false;
                }
            }
            
            var t = document.getElementsByName('buyerType');
            for (var i = 0; i < t.length; i++) {
                if (t[i].checked) {
                    document.getElementById('hdBuyerType').value = t[i].value;
                    break;
                }
            }

            if (document.getElementById('hdBuyerType').value.length == 0) {
                alert('请选择采购商类别!');
                return false;
            }
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <ext:ScriptManager ID="ScriptManager1" runat="server" />
    <uc1:top ID="Top1" runat="server" />
    <uc2:menu ID="Menu1" runat="server" />
    <div id="admin_main" style="margin: 10px 0 0 10px;">
        <ext:TabPanel runat="server" Width="650" ID="companyTab">
            <Tabs>
                <ext:Tab runat="server" AutoHeight="true" Title="供应商编辑" Frame="true">
                    <Body>
                        <div id="admin_edit_content">
                            <ul>
                                <li>
                                    <label>
                                        企业名称 *
                                    </label>
                                    <asp:TextBox runat="server" ID="txtSellerCompanyName" Width="303"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        供应商类型*
                                    </label>
                                    <asp:DropDownList runat="server" ID="ddlSellerType" DataTextField="name" DataValueField="xm">
                                    </asp:DropDownList>
                                </li>
                                <li>
                                    <label>
                                        供应商级别*
                                    </label>
                                    <asp:DropDownList runat="server" ID="ddlSellerCompanyClass" DataTextField="name" DataValueField="xm">
                                    </asp:DropDownList>
                                </li>
                                <li>
                                    <label>
                                        供应能力度 *</label>
                                    <asp:ListView runat="server" ID="rptSupplyclassMap" GroupItemCount="7">
                                        <ItemTemplate>
                                            <td>
                                                <input type="checkbox" id='chk_supplyclass_<%#Eval("xm") %>' value='<%#Eval("xm") %>' <%#Convert.ToBoolean(Eval("isChecked"))?"checked":"" %> name="supplyclassRange" /><%#Eval("name") %>
                                            </td>
                                        </ItemTemplate>
                                        <LayoutTemplate>
                                            <td runat="server" id="groupPlaceholder">
                                            </td>
                                        </LayoutTemplate>
                                        <GroupTemplate>
                                            <tr>
                                                <td runat="server" id="itemPlaceholder" />
                                            </tr>
                                        </GroupTemplate>
                                    </asp:ListView>
                                </li>
                                <li>
                                    <label>
                                        企业编号 *
                                    </label>
                                    <asp:TextBox runat="server" ID="txtSellerCompanyNo" MaxLength="8"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        地 区 *
                                    </label>
                                    <asp:DropDownList runat="server" ID="ddlSellerArea" DataTextField="name" DataValueField="xm">
                                    </asp:DropDownList>
                                </li>
                                <li>
                                    <label>
                                        详细地址 *
                                    </label>
                                    <asp:TextBox runat="server" ID="txtSellerAddress"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        摊位号 *
                                    </label>
                                    <asp:TextBox runat="server" ID="txtSellerLocation"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        固定电话
                                    </label>
                                    <asp:TextBox runat="server" ID="txtSellerPhone"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        传真号码
                                    </label>
                                    <asp:TextBox runat="server" ID="txtSellerFax"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        邮政编码
                                    </label>
                                    <asp:TextBox runat="server" ID="txtSellerPostCode" MaxLength="6"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        联系人 *
                                    </label>
                                    <asp:TextBox runat="server" ID="txtSellerContact"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        联系人手机 *
                                    </label>
                                    <asp:TextBox runat="server" ID="txtSellerMobile" MaxLength="11"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        Email
                                    </label>
                                    <asp:TextBox runat="server" ID="txtSellerEmail"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        结帐方式
                                    </label>
                                    <asp:DropDownList runat="server" ID="ddlSellerPayMethod" DataTextField="name" DataValueField="xm">
                                    </asp:DropDownList>
                                </li>
                                <li>
                                    <label>
                                        合作模式
                                    </label>
                                    <asp:RadioButton runat="server" ID="radFloat" GroupName="cooperateType" Checked="true" />浮动价格
                                    <asp:RadioButton runat="server" ID="radBranch" GroupName="cooperateType" />分成价格
                                </li>
                                <li>
                                    <label>
                                        提成
                                    </label>
                                    <asp:TextBox runat="server" ID="txtSellerCooperatePercent" Width="30" MaxLength="4"></asp:TextBox>(例：0.30表示30%) </li>
                                <li>
                                    <label>报价模式</label>
                                    <asp:RadioButton runat="server" ID="radFree" GroupName="QuotationMode" />自由报价模式
                                    <asp:RadioButton runat="server" ID="radClosed" GroupName="QuotationMode" Checked="true" />封闭报价模式
                                </li>
                                <li>
                                    <label>
                                        是否审核
                                    </label>
                                    <input runat="server" type="checkbox" checked="checked" id="chxSellerIsCheck" name="check" />是</li>
                                <li>
                                    <label>
                                        审核意见 *
                                    </label>
                                    <asp:TextBox runat="server" ID="txtSellerSuggest" TextMode="MultiLine" Width="300" Height="50"></asp:TextBox>
                                </li>
                                <li>
                                    <label>&nbsp;</label>
                                    <span style="<%=power>=2?"": "display:none" %>">
                                        <asp:Button runat="server" ID="btn_Selller_Save" Text="保 存" OnClick="btn_Selller_Save_Click" OnClientClick="return sellerInfoValidate()" />
                                    </span>
                                    <input type="button" id="btn_Return" value="返 回" onclick="window.location.href='companylist.aspx'" /></li>
                            </ul>
                        </div>
                    </Body>
                </ext:Tab>
                <ext:Tab runat="server" AutoHeight="true" Title="采购商编辑" Frame="true">
                    <Body>
                        <div id="admin_edit_content">
                            <ul>
                                <li>
                                    <label>
                                        企业名称 *
                                    </label>
                                    <asp:TextBox runat="server" ID="txtBuyerCompanyName" Width="303"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        采购商类别 *
                                    </label>
                                    <asp:Repeater runat="server" ID="rpt_buyerType">
                                        <ItemTemplate>
                                            <input type="radio" id='rad_buyerType<%#Eval("xm") %>' value='<%#Eval("xm") %>' <%#Convert.ToBoolean(Eval("isChecked"))?"checked":"" %>
                                                name="buyerType" /><%#Eval("name") %>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </li>
                                <li>
                                    <label>
                                        采购商级别</label>
                                    <asp:DropDownList runat="server" ID="ddlBuyerNature" DataTextField="name" DataValueField="xm">
                                    </asp:DropDownList>
                                </li>
                                <li>
                                    <label>
                                        销售员
                                    </label>
                                    <asp:DropDownList runat="server" ID="ddl_SalesPerson" DataTextField="username" DataValueField="adminId">
                                    </asp:DropDownList>
                                </li>
                                <li>
                                    <label>
                                        企业编号 *
                                    </label>
                                    <asp:TextBox runat="server" ID="txtBuyerCompanyNo" MaxLength="8"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        地 区 *
                                    </label>
                                    <asp:DropDownList runat="server" ID="ddlBuyerArea" DataTextField="name" DataValueField="xm">
                                    </asp:DropDownList>
                                </li>
                                <li>
                                    <label>
                                        详细地址 *
                                    </label>
                                    <asp:TextBox runat="server" ID="txtBuyerAddress"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        固定电话
                                    </label>
                                    <asp:TextBox runat="server" ID="txtBuyerPhone"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        传真号码
                                    </label>
                                    <asp:TextBox runat="server" ID="txtBuyerFax"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        邮政编码
                                    </label>
                                    <asp:TextBox runat="server" ID="txtBuyerPostCode" MaxLength="6"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        用餐人数
                                    </label>
                                    <asp:TextBox runat="server" ID="txtBuyerEatPerson" MaxLength="20"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        联系人 *
                                    </label>
                                    <asp:TextBox runat="server" ID="txtBuyerContact"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        身份证号码
                                    </label>
                                    <asp:TextBox runat="server" ID="txtBuyerIDCard"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        联系人手机 *
                                    </label>
                                    <asp:TextBox runat="server" ID="txtBuyerMobile" MaxLength="11"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        Email
                                    </label>
                                    <asp:TextBox runat="server" ID="txtBuyerEmail"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        结帐方式
                                    </label>
                                    <asp:DropDownList runat="server" ID="ddlBuyerPayMethod" DataTextField="name" DataValueField="xm">
                                    </asp:DropDownList>
                                </li>
                                <li>
                                    <label>
                                        生成账单日
                                    </label>
                                    <asp:TextBox runat="server" ID="txtBuyerPayDay" Width="80px"></asp:TextBox>
                                    <span style="color: Red">(如：需要生成4月26日-5月25日,26号为生成日,没有指定日,则不填)</span>
                                </li>
                                <li>
                                    <label>
                                        送货时间 *</label>
                                    <asp:DropDownList runat="server" ID="ddlBuyerReceiveTime" DataTextField="name" DataValueField="xm">
                                    </asp:DropDownList>
                                </li>
                                <li>
                                    <label>
                                        是否审核
                                    </label>
                                    <input runat="server" type="checkbox" checked="checked" id="chxBuyerIsCheck" name="check" />是</li>
                                <li>
                                    <label>
                                        审核意见 *
                                    </label>
                                    <asp:TextBox runat="server" ID="txtBuyerSuggest" TextMode="MultiLine" Width="300"
                                        Height="50"></asp:TextBox>
                                </li>
                                <li>
                                    <label>
                                        是否启用固定价</label>
                                    <asp:CheckBox runat="server" ID="chkBuyerWeeklyPrice" />
                                </li>
                                <li>
                                    <label>
                                        &nbsp;
                                    </label>
                                    <span style="<%=power>=2?"": "display:none" %>">
                                        <asp:Button runat="server" ID="btn_Buyer_Save" Text="保 存" OnClick="btn_Buyer_Save_Click" OnClientClick="return buyerInfoValidate()" />
                                    </span>
                                    <input type="button" value="返 回" onclick="window.location.href='companylist.aspx'" />
                                </li>
                            </ul>
                        </div>
                    </Body>
                </ext:Tab>
            </Tabs>
        </ext:TabPanel>
    </div>
    <asp:HiddenField runat="server" ID="hdBuyerType" />
    <asp:HiddenField runat="server" ID="hdSellerBusinessNatures" />
    </form>
</body>
</html>
